using System.Data;
using Common;
using DAL;
using Model;

namespace BLL {
    public class CategoryBLL {
        private CategoryBLL(){}
        private static readonly CategoryBLL Instance = new CategoryBLL();
        private CategoryDAL _categoryDal = CategoryDAL.GetInstance();
        public static CategoryBLL GetInstance() {
            return Instance;
        }

        public DataTable GetAllCategory() {
            return _categoryDal.SelectAllCategory();
        }

        public Result<Category> UpdateCategory(Category category) {
            return _categoryDal.UpdateCategory(category) == 1 ? Result<Category>.Ok("success") : Result<Category>.Error("error");
        }

        public Result<Category> DeleteCategory(Category category) {
            return _categoryDal.DeleteCategory(category) == 1 ? Result<Category>.Ok("success") : Result<Category>.Error("error");
        }
    }
}